﻿<UserControl x:Class="Chapters.Chapter13.TwirlEffect_Tester"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:Chapter13="clr-namespace:FSharp.Chapter13;assembly=FSharpLibrary">
	<DockPanel>
		<StackPanel DockPanel.Dock="Left"
					Width="200">
			<TextBlock Text="{Binding Value, ElementName=_radiusSlider, StringFormat=Radius: {0:F2}}" />
					<Slider x:Name="_radiusSlider"
							Minimum="0"
							Maximum="3"
							SmallChange="0.5" />
					<TextBlock Margin="0,10,0,0"
							   Text="{Binding Value, ElementName=_angleSlider, StringFormat=Angle: {0:F2}}" />
					<Slider x:Name="_angleSlider"
							Minimum="0"
							Maximum="45"
							SmallChange="5" />
					<GroupBox Header="Animation"
							  Padding="5"
							  Margin="0,20,0,0">
						<StackPanel>
							<Button x:Name="_animate"
									Margin="0,8,0,8">Start</Button>
							<Button x:Name="_reset">Reset</Button>
						</StackPanel>
					</GroupBox>
				</StackPanel>
		<Image Source="/Resources;component/Shared/toucan.jpg"
			   Stretch="Fill">
			<Image.Effect>
				<Chapter13:TwirlEffect x:Name="_twirlEffect"
									   Radius="{Binding Value, ElementName=_radiusSlider}"
									   Angle="{Binding Value, ElementName=_angleSlider}" />
			</Image.Effect>
		</Image>
	</DockPanel>

	<UserControl.Triggers>
		<EventTrigger RoutedEvent="Button.Click"
					  SourceName="_animate">
			<BeginStoryboard x:Name="_effectAnimator">
				<Storyboard>
					<DoubleAnimation To="0"
									 Duration="0:0:1"
									 Storyboard.TargetName="_twirlEffect"
									 Storyboard.TargetProperty="Radius" />
					<DoubleAnimation To="0"
									 Duration="0:0:1"
									 Storyboard.TargetName="_twirlEffect"
									 Storyboard.TargetProperty="Angle" />
				</Storyboard>
			</BeginStoryboard>
		</EventTrigger>

		<EventTrigger RoutedEvent="Button.Click"
					  SourceName="_reset">
			<RemoveStoryboard BeginStoryboardName="_effectAnimator" />
		</EventTrigger>
	</UserControl.Triggers>
</UserControl>
